﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Common.DTO;
using LogicLayer;

namespace ImmoralServices
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class GameService : IGameService
    {
        public Boolean CreateGamesession(int playerId, int gameId, int rounds)
        {
            return GameHandler.CreateGamesession(playerId, gameId, rounds);
        }

        public Boolean DeleteGameSession(int sessionId)
        {
            return GameHandler.DeleteGameSession(sessionId);
        }

        public Boolean DeletePlayerSession(int playerId, int sessionId)
        {
            return GameHandler.DeletePlayerSession(playerId, sessionId);
        }     

        public Boolean UpdateGameRounds(int id, int rounds)
        {
            return GameHandler.UpdateGameRounds(id, rounds);
        }

        public List<GameSession> GetGameSession(string namn)
        {
            return GameHandler.GetGameSession(namn);
        }

        public List<Game> GetGame()
        {
            return GameHandler.GetGameList();
        }

        public Boolean AddPlayerSession(int playerId, int sessionId)
        {
            return PlayerHandler.AddPlayerSession(playerId, sessionId);
        }

        public List<GameSession> GetAllActiveGameSessions()
        {
            return GameHandler.GetAllActiveGameSessions();
        }

        public bool MakePlayerChoice(int gameSessionId, int playerId, int playerChoiceId)
        {
            return PlayerHandler.MakePlayerChoice(gameSessionId, playerId, playerChoiceId);
        }

        public bool CheckOpponentStatus_dummy(int playerId, int gameSessionId)
        {
            return CommonHandler.CheckOpponentStatus(playerId, gameSessionId);
        }

        public GameInfo CheckIfGameRoundIsFinished_dummy(int gameSessionId)
        {
            return CommonHandler.CheckIfGameRoundIsFinished(gameSessionId);
        }

        public Player GetSessionsWinner(int gameSessionId)
        {
            return LogicLayer.GameHandler.GetSessionWinner(gameSessionId);
        }

        public List<GameSession> GetPlayersGameSessions(int playerID)
        {
            return LogicLayer.GameHandler.GetPlayersGameSessions(playerID);
        }

        public List<GameSession> GetJoinableGameSessions(int gameID, int playerId)
        {
            return GameHandler.GetAllJoinableGameSessions(gameID, playerId);
        }
    }
}
